package com.huitone.gddw.controller.monitoring;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.huitone.gddw.dao.entity.Pid;
import com.huitone.gddw.dao.entity.ReturnedValue;

import com.huitone.gddw.service.SystemMonitoringService;
import com.huitone.gddw.utils.MonitoringResult;

/**
 * 系统监控的Controller
 * @author lipengfei
 *
 */
@Controller
@RequestMapping(value="sysmon")
public class SystemMonitoringController {
	private final static Logger LOGGER = Logger.getLogger(SystemMonitoringController.class);
	
	@Resource
	SystemMonitoringService sysService;
	@ResponseBody
	@RequestMapping(value="/showSys",method=RequestMethod.POST)
	public MonitoringResult<Map<String, Object>> show(){
		MonitoringResult<Map<String, Object>> result = 
				sysService.loadSysInformation();
		LOGGER.info("显示系统监控的数据完成");
		return result;
	}
	@ResponseBody
	@RequestMapping(value="/hostSys",method=RequestMethod.POST)
	public MonitoringResult<Map<String, Object>> hostShow(ReturnedValue value){
		MonitoringResult<Map<String, Object>> result = 
				sysService.loadSysInformationByHost(value);
		LOGGER.info("显示系统监控的数据完成");
		return result;
	}
	@ResponseBody
	@RequestMapping(value="/showPid",method=RequestMethod.POST)
	public MonitoringResult<Map<String, Object>> showPid(ReturnedValue value){
		MonitoringResult<Map<String, Object>> result = 
				sysService.loadPidInformation();
		LOGGER.info("显示进程监控的数据完成");
		return result;
	}
	@ResponseBody
	@RequestMapping(value="/hostPid",method=RequestMethod.POST)
	public MonitoringResult<Map<String, Object>> showPidByHost(ReturnedValue value){
		MonitoringResult<Map<String, Object>> result = 
				sysService.loadPidInformationByHost(value);
		LOGGER.info("根据主机显示pid监控的数据");
		return result;
	}
	@ResponseBody
	@RequestMapping(value="/addIndex",method=RequestMethod.POST)
	public MonitoringResult<Map<String, Object>> addIndex(ReturnedValue value){
		MonitoringResult<Map<String, Object>> result = 
				sysService.addIndex(value);
		LOGGER.info("显示系统监控的数据完成");
		return result;
	}
	@ResponseBody
	@RequestMapping(value="/saveIndex",method=RequestMethod.POST)
	public MonitoringResult<Pid> saveIndex(ReturnedValue value){
		MonitoringResult<Pid> result = 
				sysService.save(value);
		LOGGER.info("显示系统监控的数据完成");
		return result;
	}
	
	
}
